#ifndef VISITOR_H
#define VISITOR_H

#include "AstNode.h"

// 访问器
class AstVisitor {
public:
    virtual void VisitProgramNode(ProgramAstNode *node) {}
    virtual void VisitFunctionNode(FunctionNode *node) {}
    virtual void VisitExprStatmNode(ExprStatmNode *node) {}
    virtual void VisitFuncCallNode(FuncCallNode *node) {}
    virtual void VisitDeclarationStatmNode(DeclarationStatmNode *node) {}
    virtual void VisitIfStatmNode(IfStatmNode *node) {}
    virtual void VisitWhileStatmNode(WhileStatmNode *node) {}
    virtual void VisitForStatmNode(ForStatmNode *node) {}
    virtual void VisitReturnStatmNode(ReturnStatmNode *node) {}
    virtual void VisitBlockStatmNode(BlockStatmNode *node) {}
    virtual void VisitAssignExprNode(AssignExprNode *node) {}
    virtual void VisitBinaryNode(BinaryAstNode *node) {}
    virtual void VisitUnaryNode(UnaryAstNode *node) {}
    virtual void VisitConstantNode(ConstantAstNode *node) {}
    virtual void VisitSizeofNode(SizeofNode *node) {}
    virtual void VisitVarNode(VarAstNode *node) {}
};

class PrintVisitor : public AstVisitor {
public:
    std::string Content;

    void VisitProgramNode(ProgramAstNode *node) override;
    void VisitFunctionNode(FunctionNode *node) override;
    void VisitExprStatmNode(ExprStatmNode *node) override;
    void VisitFuncCallNode(FuncCallNode *node) override;
    void VisitDeclarationStatmNode(DeclarationStatmNode *node) override;
    void VisitIfStatmNode(IfStatmNode *node) override;
    void VisitWhileStatmNode(WhileStatmNode *node) override;
    void VisitForStatmNode(ForStatmNode *node) override;
    void VisitReturnStatmNode(ReturnStatmNode *node) override;
    void VisitBlockStatmNode(BlockStatmNode *node) override;
    void VisitAssignExprNode(AssignExprNode *node) override;
    void VisitBinaryNode(BinaryAstNode *node) override;
    void VisitUnaryNode(UnaryAstNode *node) override;
    void VisitConstantNode(ConstantAstNode *node) override;
    void VisitSizeofNode(SizeofNode *node) override;
    void VisitVarNode(VarAstNode *node) override;
};

#endif // !VISITOR_H
